<template>
  <div>
    <div class="swipe-wrapper">
      <van-swipe :autoplay="5000">
        <van-swipe-item class="item" v-for="(item, index) in banner" :key="index">
          <img :src="item" @click="goTo(item.url)" :href="item.url" ref="img"/>
        </van-swipe-item>
      </van-swipe>
    </div>
  </div>
</template>

<script type="text/ecmascript-6">
  export default {
    name: 'banner1',
    props: {
      banner: {
        type: Array
      }
    },
    data() {
      return {
        url: ''
      };
    },
    created() {
    },
    methods: {
      goTo(e) {
        if (e && e !== '') {
          window.location.href = e;
        }
      }
    }
  };
</script>

<style lang="stylus" rel="stylesheet/stylus" scoped>
  @import "../../assets/stylus/main.styl"
  .van-swipe-item{
    float: left;
    height: auto;
  }
  img[lazy=loading]{
    width:30vw;
    margin 8vw auto
  }
  .swipe-wrapper{
    width: 100vw;
    height: vw(375);
  }
  .item{
    text-align center
    & img{
      width:100vw;
    }
  }
</style>
